package com.hmall.mapper;

import com.hmall.model.MallOrder;
import com.hmall.util.MyMapper;
import com.hmall.vo.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
@Repository
public interface MallOrderMapper extends MyMapper<MallOrder> {
    MallOrder selectByUserIdAndOrderNo(@Param("userId") Integer userId, @Param("orderNo") Long orderNo);

    MallOrder selectByOrderNo(Long orderNo);

    List<MallOrder> selectByUserId(Integer userId);

    List<MallOrder> selectAllOrder();

    List<MallOrderManageVo> selectOrder();

    List<MallOrderManageVo> selectSHZOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectWFKOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectYQXOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectYFKOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectYFHOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectJYCGOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectWQHTOrder(@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectHTSXOrder(@Param("dept_id") Integer dept_id);

    Integer cancelOrder(Integer id);

    Integer deliverOrder(Integer id);

    Integer updatePayment(@Param("orderId") Integer orderId, @Param("change_price") BigDecimal change_price);

    Integer updateOrder(@Param("id")Integer id,@Param("shipping_id") Integer shipping_id,@Param("distCode") Integer distCode);

    int updateByOrderId(String status, Integer orderId);

    int updateByOrderNo(@Param("status") Integer status, @Param("order_no") Long order_no);
    //创建订单
    int insertOrder(@Param("order")MallOrder order);
    //批量创建订单
    int batchInsertOrder(@Param("orderList")List<OrderSelectVo> orderList);

    //查询最近三个月订单
     List<OrderSelectVo> selectOrderItemsByThreeMonth(
            @Param("status") String status,
            @Param("userId") Integer userId,
            @Param("startPage") Integer startPage,
            @Param("pageSize") Integer pageSize
    ) ;
    //查询最近三个月所有订单
     List<OrderSelectVo> selectAllOrderItemsByThreeMonth(

            @Param("userId") Integer userId,
            @Param("startPage") Integer startPage,
            @Param("pageSize") Integer pageSize
    ) ;
    //订单号查询订单
     OrderSelectVo selectOrderByOrderNo(@Param("oderNo") Long oderNo) ;
     //查询某个订单下的产品列表
    List<OrderSelectItemVo> selectOrderItemsByOrderNo(@Param("orderNo") Long orderNo);
    int selectOrderByThreeMonthCount( @Param("status") String status,
                                      @Param("userId") Integer userId);
    int selectAllOrderByThreeMonthCount(
                                      @Param("userId") Integer userId);

    //列出状态为50(交易成功) 的所有订单编号
    List<BigInteger> listSuccessOrderNo(@Param("SUCCESS") int SUCCESS);

    //列出状态为50（交易成功）的某个用户的所有订单编号
    List<BigInteger> listSuccessUserOrderNo(@Param("userId") Integer userId, @Param("SUCCESS") int success);

    //列出状态为50(交易成功)的更新时间
    Date selectUpdateTime(@Param("status") int status, @Param("productId") Integer productId);

    //删除某个用户的所有订单
    void deleteByUserId(@Param("userId") Integer userId);

    void changeOrderStatus(@Param("orderId") Integer orderId, @Param("status") Integer status);

    List<MallOrder> findOrderStatus(@Param("userId") Integer userId);

    List<MallOrderManageVo> selectListByNo(@Param("query") String query, @Param("type") Integer type,@Param("dept_id")Integer dept_id);

    List<MallOrderManageVo> selectSampleOrder(@Param("status") Integer status,@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectSampleListByNo(@Param("order_no") String order_no, @Param("dept_id") Integer dept_id, @Param("status") Integer status, String bus_name);

    List<MallOrderManageVo> selectDealerOrder(@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> selectSampleDealerOrder(@Param("status") Integer status,@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectDealerList(@Param("query") String query,@Param("type") Integer type,@Param("dept_id") Integer dept_id);

    List<MallOrderManageVo> selectDealerSampleList(@Param("order_no") String order_no, @Param("dept_id") Integer dept_id, @Param("status") Integer status,@Param("bus_name") String bus_name);

    List<MallOrder> selectByMonth(@Param("dealer_id") Integer dealer_id, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<MallOrder> selectByUserIdAndMonth(@Param("user_id") int user_id,@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    List<MallOrderManageVo> selectTotalOrder(@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> selectMyDealerOrder(@Param("status") Integer status,@Param("user_id") Integer user_id,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    void updateOrderPrice(@Param("order_no") Long order_no,@Param("payment") BigDecimal payment);

    List<MallOrderManageVo> searchMyDealerOrder(@Param("order_no") String order_no, @Param("status") Integer status, @Param("user_id") Integer user_id,@Param("bus_name") String bus_name,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> searchDealerOrder(@Param("order_no") String order_no, @Param("status") Integer status, @Param("dept_id") Integer dept_id,@Param("bus_name") String bus_name,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> searchTotalOrder(@Param("order_no") String order_no, @Param("status") Integer status, @Param("dept_id") Integer dept_id,@Param("bus_name") String bus_name,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> selectSalesManSampleDealerOrder(@Param("status") Integer status,@Param("user_id") Integer user_id);

    Integer selectByDeptIdAndTime(@Param("dept_id") Integer dept_id,@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    Integer selectByTime(@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    List<MallOrder> selectOrderByTime(@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    List<MallOrderManageVo> searchSalesManSampleOrder(@Param("order_no") String order_no, @Param("status") Integer status, @Param("user_id") Integer user_id,@Param("bus_name") String bus_name);

    List<MallOrder> selectPassOrderByCustomerId(@Param("customerId") Integer customerId);

    void changeDealer(@Param("customer_id") Integer customer_id,@Param("oldDealerId") Integer oldDealerId,@Param("oldDealerId") Integer newDealerId);

    Integer checkOrderNum(@Param("customer_id")Integer customer_id, @Param("oldDealerId") Integer oldDealerId);

    List<MallOrderManageVo> selectManageOrder(@Param("status") Integer status,@Param("user_id") Integer user_id,@Param("order_no") String order_no,@Param("bus_name") String bus_name,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> selectMyTotalOrder(@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("order_no") String order_no,@Param("bus_name") String bus_name,@Param("pageStart") Integer pageStart,@Param("pageSize") Integer pageSize);

    List<MallOrderManageVo> selectMyTotalOrder2(@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("order_no") String order_no,@Param("bus_name") String bus_name);

    List<MallOrderManageVo> selectManageOrder2(@Param("status")Integer status,@Param("user_id") Integer user_id,@Param("order_no") String order_no,@Param("bus_name") String bus_name);

    MallOrder selectInsertOrder();

    Integer selectDealerOrderCount(@Param("status") Integer status,@Param("dept_id") Integer dept_id);

    Integer selectTotalOrderCount(@Param("status") Integer status,@Param("dept_id") Integer dept_id);

    Integer searchDealerOrderCount(@Param("order_no") String order_no,@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("bus_name") String bus_name);

    Integer searchTotalOrderCount(@Param("order_no") String order_no,@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("bus_name") String bus_name);

    Integer searchMyDealerOrderCount(@Param("order_no")String order_no,@Param("status") Integer status,@Param("user_id") Integer user_id,@Param("bus_name") String bus_name);

    Integer selectMyDealerOrderCount(@Param("status") Integer status,@Param("user_id") Integer user_id);

    Integer selectMyTotalOrderCount(@Param("status") Integer status,@Param("dept_id") Integer dept_id,@Param("order_no") String order_no,@Param("bus_name") String bus_name);

    Integer selectManageOrderCount(@Param("status") Integer status,@Param("user_id") Integer user_id,@Param("order_no") String order_no,@Param("bus_name") String bus_name);

    List<MallOrder> selectMonthPassOrderByCustomerId(@Param("customerId") Integer customerId,@Param("startTime") Date startTime,@Param("endTime") Date endTime);

    List<MallOrder> selectByDay(@Param("dealer_id") Integer dealer_id, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<DataVo> selectMonthProduct(@Param("dealer_id") Integer dealer_id, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<DataVo> selectMonthOrderArea(@Param("dealer_id") Integer dealer_id, @Param("startTime") Date startTime, @Param("endTime") Date endTime);

    BigDecimal selectTotalSum(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    BigDecimal selectTotalPrice(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    List<DataVo> selectProductQuantity(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    List<DataVo> selectProductQuantity2(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    List<DataVo> selectProductPrice(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    List<DataVo> selectProductPrice2(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    Integer selectCount1(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    BigDecimal selectCount2(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    Integer selectCount3(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    BigDecimal selectCount4(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    List<DataVo2> selectDeviceTypeCountList(@Param("startTime")Date startTime, @Param("endTime") Date endTime);

    List<DataVo2> selectPurchaseTypeCountList(@Param("startTime")Date startTime,@Param("endTime") Date endTime);
}